package cn.com.nwpu.visual_system.tool;

import org.springframework.core.io.ClassPathResource;

import java.io.IOException;

/**
 * @author Hutengzhong
 * @version 1.0.0
 * @title GetUrl
 * @description 获取python文件路径
 * @date 2024/5/16 10:43
 */
public class GetUrl {
    public String getValuePath(String fileName) {
        ClassPathResource classPathResource = new ClassPathResource("script/python/model/"+ fileName + ".txt");
        String url = null;
        try {
            url = classPathResource.getURI().getPath();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        url = url.substring(1);
        return url;
    }

    public String getPythonUrl() {
        ClassPathResource classPathResource = new ClassPathResource("script/python/");
        String url = null;
        try {
            url = classPathResource.getURI().getPath();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        url = url.substring(1);
        return url;
    }

    public String getPythonUrl(String fileName) {
        ClassPathResource classPathResource = new ClassPathResource("script/python/" + fileName + ".py");
        String url;
        try {
            url = classPathResource.getURI().getPath();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        url = url.substring(1);
        return url;
    }
}
